package com.swpu.course_schedule.service.Impl;

import com.swpu.course_schedule.POJO.Course.Classroom;
import com.swpu.course_schedule.POJO.Course.ClassroomCourseArrange;
import com.swpu.course_schedule.POJO.Course.CourseArrange;
import com.swpu.course_schedule.service.ClassroomCourseArrangeService;

import java.util.ArrayList;
import java.util.List;

public class ClassroomCourseArrangeImpl implements ClassroomCourseArrangeService {

    /**
     * 将教室和其对应的课程封装为一个对象
     * @param classrooms 教室列表
     * @param courseArranges 所有课程的列表
     * @return 每个教室的课程安排
     */
    @Override
    public List<ClassroomCourseArrange> getClassroomArrangeInfo
            (List<Classroom> classrooms, List<CourseArrange> courseArranges) {
        List<ClassroomCourseArrange> roomsArrange = new ArrayList<ClassroomCourseArrange>();
        // 遍历所有的教室
        for (Classroom cr :
                classrooms) {
            List<CourseArrange> roomArranges = new ArrayList<CourseArrange>();
            // 遍历所有的课程，筛选出教室对应的课程
            for (CourseArrange ca :
                    courseArranges) {
                if (cr.getRID() == ca.getRID()){
                    roomArranges.add(ca);
                }
            }
            //
            ClassroomCourseArrange arrange = new ClassroomCourseArrange();
            arrange.setClassroom(cr);
            arrange.setCourseArranges(roomArranges);
            roomsArrange.add(arrange);
        }
        return roomsArrange;
    }

    @Override
    public boolean checkCourse(CourseArrange courseArrange) {
        return false;
    }

    @Override
    public boolean insertCourse(CourseArrange courseArrange) {
        return false;
    }


}
